<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组去重</title>
</head>
<body>

</body>
</html>
<script>
    var arr = [];
    for(var i=0;i<20;i++){
        arr.push(parseInt(Math.random()*10));
    }
    Array.prototype.indexOf = function(n){
        for(var i=0;i<this.length;i++){
            if(this[i] == n){
                return i;
            }
        }
        return -1;
    }
    function removeDup(arr){
        var result = [];
        for(var i=0;i<arr.length;i++){
            if(result.indexOf(arr[i]) == -1){

                result.push(arr[i]);
            }
        }
        return result;
    }
    var arr2 = removeDup(arr)
    document.write(arr+'<br/>'+arr2)
</script>